package com.lagou.homewok.mr;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;


/*
1. mapper按行读取数据
2. 按行读取的数据就是需要排序的数值
3. 使用数值作为k，null作为输出
 */
public class SortMapper extends Mapper<LongWritable, Text, LongWritable, NullWritable> {

    LongWritable k = new LongWritable();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        long num = Long.parseLong(value.toString());

        k.set(num);
        context.write(k, NullWritable.get());
    }
}
